package com.sfx.concurrent.demo.concurrent.pattern.join.GuardedTimeoutEffect;

import lombok.extern.slf4j.Slf4j;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-12-31
 * Time: 14:16
 */

@Slf4j(topic = "c.TestMain")
public class TestMain {
    public static void main(String[] args) {
        GuardedObject guardedObject = new GuardedObject();
        new Thread(()->{
            log.debug("开始");
            Object response = guardedObject.get(2000);
            log.debug("结果为{}",response);
        },"t1").start();

        new Thread(()->{
           log.debug("开始");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            guardedObject.complete(null);
        },"t2").start();
    }
}
